﻿//关闭签到窗口
function qiandao_close() {
    // 获取具有 hidden_text ID 的元素
    hiddenText = document.getElementById("Successful_check");
    // 将元素的 display 样式更改为 "block"
    hiddenText.style.display = "none";
}
//关闭签退窗口
function qiantui_close() {
    // 获取具有 hidden_text ID 的元素
    hiddenText = document.getElementById("Successful_tui");
    // 将元素的 display 样式更改为 "block"
    hiddenText.style.display = "none";


}

// 点击签到的日期
function qiandao() {
    // 获取具有 hidden_text ID 的元素
    hiddenText = document.getElementById("Successful_check");
    // 将元素的 display 样式更改为 "block"
    hiddenText.style.display = "block";
    // 获取具有 hidden_text ID 的元素
    hiddenText = document.getElementById("Successful_tui");
    // 将元素的 display 样式更改为 "block"
    hiddenText.style.display = "none";
  

    //打卡时间
    var now = new Date();
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hour = now.getHours();
    var minute = now.getMinutes();
    var second = now.getSeconds();
    var week = ["日", "一", "二", "三", "四", "五", "六"][now.getDay()];
    var dateStrche = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
    document.getElementById("date_check").innerHTML = dateStrche;

    window.location("/home/ADDattendance_records")

}


// 点击签退的日期
function qiantui() {
    // 获取具有 hidden_text ID 的元素
    hiddenText = document.getElementById("Successful_tui");
    // 将元素的 display 样式更改为 "block"
    hiddenText.style.display = "block";
    // 获取具有 hidden_text ID 的元素
    hiddenText = document.getElementById("Successful_check");
    // 将元素的 display 样式更改为 "block"
    hiddenText.style.display = "none";

    //打卡时间
    var now = new Date();
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hour = now.getHours();
    var minute = now.getMinutes();
    var second = now.getSeconds();
    var week = ["日", "一", "二", "三", "四", "五", "六"][now.getDay()];
    var dateStrche = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
    document.getElementById("date_tui").innerHTML = dateStrche;
}
//  获取时间
function updateTime() {
    var now = new Date();
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hour = now.getHours();
    var minute = now.getMinutes();
    var second = now.getSeconds();
    var week = ["日", "一", "二", "三", "四", "五", "六"][now.getDay()];
    var dateStr = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second + " 星期" + week;
    document.getElementById("new_date").innerHTML = dateStr;
}
//实时更新
setInterval(updateTime, 0);




$(document).ready(function () {
    $('.qiandao').click(function () {
        $.getJSON('https://ipapi.co/json/', function (data) {
            $('#ip_addr').text(data.ip);
        }).fail(function () {
            console.error('Error fetching location information');
        });
        $('#ip_addr').show();
    });


    $('.qiantui').click(function () {
        $.getJSON('https://ipapi.co/json/', function (data) {
            $('#ip_addr').text(data.ip);
        }).fail(function () {
            console.error('Error fetching location information');
        });
        $('#ip_addr').show();
    });
});

window.onload = function () {
    var touxiang = @ViewBag.touxiang;
    if (touxiang) {
        /*需要网络才能获取QQ头像*/
        var url = 'https://q1.qlogo.cn/g?b=qq&nk=' + touxiang + '&s=100&t=0';
        var QQ_hdad = document.getElementById("QQ_hdad");
        QQ_hdad.src = url;
    }
    else {
        QQ_hdad.src = "~/images/头像/WCH1.jpg";
    }
}